/* Does the thread stuff. Gross hack.
 * $Id: thread.h,v 1.1.1.1 2003/01/14 02:55:06 root Exp $
 *
 * $Log: thread.h,v $
 * Revision 1.1.1.1  2003/01/14 02:55:06  root
 * Created Ultcp directory structure
 *
 * Revision 1.2  2002/08/09 14:04:23  kandula
 * Bug-Fixed Version of ULTCP. Added 08/09/2002
 *
 * Revision 3.2  1999/12/18 16:27:38  kaf24
 * Performance tweaks
 *
 * Revision 3.1  1999/12/18 16:27:26  kaf24
 * Performance tweaks
 *
 * Revision 3.0  1999/12/17 11:37:01  kaf24
 * Now uses Linux stack.
 *
 * Revision 2.5  1999/12/17 11:36:21  kaf24
 * Now uses Linux stack.
 *
 * Revision 2.4  1999/11/01 15:33:25  kaf24
 * before changing to new tx2 send path
 *
 * Revision 2.3  1999/10/07 10:49:47  kaf24
 * Changed to Gnu pth thread lib.
 *
 * Revision 2.2  1999/10/01 08:12:36  kaf24
 * clean interface to USD details. Bugs in hash code but ready for change to pth threads.
 *
 * Revision 2.1  1999/09/28 13:02:34  kaf24
 * Performance enhancements, before changing thread lib.
 *
 * Revision 2.0  1999/09/23 13:27:03  kaf24
 * Bug fixes, and added SOCK_USER
 *
 * Revision 1.6  1999/08/06 14:41:36  kaf24
 *  First working UDP version for acenic gigabit ethernet.
 *
 * Revision 1.5  1999/08/02 14:00:32  kaf24
 * Removed pthread references.
 *
 * Revision 1.4  1999/07/22 14:58:54  kaf24
 * Removed non-compiled code
 *
 * Revision 1.3  1998/02/26 10:36:13  dbs20
 * First version with simulator and new buffering methods.
 *
 * Revision 1.2  1998/01/21 11:04:55  dbs20
 * ,
 *
 * Revision 1.1  1998/01/09 14:06:05  dbs20
 * Initial revision
 *
 */

#ifndef _THREAD_H_
#define _THREAD_H_

#include "defines.h"

#ifdef USE_PTH
#include <pth.h>
#endif

/*
typedef pth_t       pthread_t;
typedef pth_mutex_t pthread_mutex_t;
typedef pth_cond_t  pthread_cond_t;
*/

#ifndef USE_PTH

#define pth_mutex_acquire(a,b,c) ((void) 0)
#define pth_mutex_release(a,b,c) ((void) 0)

#define pthread_create(__thr, __attr, __start, __arg) ((void)0)
#define pthread_cancel(__t) ((void)0)
#define pthread_join(__t, __r) ((void)0)
#define pthread_setcanceltype(__t, __o) ((void)0)
#define sched_yield() ((void)0)

#define PTHREAD_MUTEX_INITIALIZER PTH_MUTEX_INIT
#define pthread_mutex_init(__x, __t) ((void)0)
#define pthread_mutex_lock(__x) ((void)0)
#define pthread_mutex_unlock(__x) ((void)0)
#define pthread_mutex_destroy(__x) ((void)0)

#define PTHREAD_COND_INITIALIZER PTH_COND_INIT
#define pthread_cond_init(__x, __t) ((void)0)
#define pthread_cond_wait(__c, __m) ((void)0)
#define pthread_cond_signal(__c) ((void)0)
#define pthread_cond_broadcast(__c) ((void)0)
#define pthread_cond_destroy(__x) ((void)0)
#endif 


/******************************************************************************
 * To be used if the wait is not related to a pcb structure. We use DB
 * rather than FDB.
 */
#define WAIT_NO_PCB(_cond, _cond_variable, _lock)       \
    while ( !(_cond) )                                  \
    {                                                   \
        DB("waiting (%p)", &(_cond_variable));          \
        pthread_cond_wait(&(_cond_variable), &(_lock)); \
        DB("awoken (%p)", &(_cond_variable));           \
    }

#endif _THREAD_H_
/* end of $RCSfile: thread.h,v $ */
